﻿using HMS.Data;
using HMS.DataContract.Request;
using HMS.DataContract.Response;
using HMS.DataContract.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HMS.DataContact.Response;

namespace HMS.Facade
{
    public class ReportFacade
    {
        public List<PatientLocationReportResponse> LocationBasedPatientCount(DateTime startDate, DateTime endDate, int clinicId, int locId, int docId)
        {
            ReportService _service = new ReportService();
            List<DoctorAppointmentResponse> lstDocAppt = new List<DoctorAppointmentResponse>();
            var patientLocationCount = _service.LocationBasedPatientCount(startDate, endDate,clinicId, locId, docId);
            List<PatientLocationReportResponse> patientLocationReportResponse = new List<PatientLocationReportResponse>();
            foreach (var item in patientLocationCount)
            {
                patientLocationReportResponse.Add(new PatientLocationReportResponse() { 
                                                        PatientCount = item.PatientCount.GetHashCode(),
                                                        Patient_Location_Name = item.Patient_Location_Name,
                                                        Patient_Name = item.Patient_Name
                                                    });
            }
            return patientLocationReportResponse;
        }

        public List<FinanceReportResponse> GetFinanceReport(DateTime startDate, DateTime endDate, int clinicId, int locId, int docId)
        {
            ReportService _service = new ReportService();
            List<FinanceReportResponse> lstReport = new List<FinanceReportResponse>();
            var financeReport = _service.GetFinanceReport(startDate, endDate, clinicId, locId, docId);
            foreach (var item in financeReport)
            {
                FinanceReportResponse fr = new FinanceReportResponse();
                fr.Appt_Date = item.Appt_Date.GetValueOrDefault();
                fr._Appt_Date = item.Appt_Date.GetValueOrDefault().ToString("dd/MMM/yyyy");
                fr.Patient_Name = item.Patient_Name;
                fr.Amt_Paid = item.Amt_Paid;
                fr.Total = item.Total;
                fr.Balance = item.Total - item.Amt_Paid;
                lstReport.Add(fr);
            }
            return lstReport;
        }
    }
}
